package com.rankeiot.core.util.castor;




import org.sagacity.sqltoy.utils.DateUtil;

import java.util.Date;

@SuppressWarnings("AlibabaConstantFieldShouldBeUpperCase")
public class DateCastor implements Castor<Date> {
    public static final DateCastor instance=new DateCastor();
    private DateCastor(){}
    @Override
    public Date cast(Object v) {
        if(v==null){
            return null;
        }else if(v instanceof Date){
            return (Date)v;
        }else if(v instanceof Number){
            return new Date(((Number)v).longValue());
        }

        return DateUtil.parseString(v.toString());
    }
}
